import {Component, Input} from '@angular/core';
import {NgClass} from '@angular/common';

@Component({
  selector: 'app-accordion',
  imports: [
    NgClass
  ],
  templateUrl: './accordion.html',
  styleUrl: './accordion.css'
})
export class Accordion {
  @Input() items:any[] | undefined;

  openedItemIndex = 0;

  onClick(index:number){
    if(index === this.openedItemIndex){
      this.openedItemIndex = -1;
    }else{
      this.openedItemIndex = index;
    }
  }
}
